import { ref } from 'vue'
import { defineStore } from 'pinia'
import type { UserLoginType } from '@/types'

export const useUserStore = defineStore(
  'user',
  () => {
    //用户登录返回信息
    const userLoginState = ref<UserLoginType>()

    //用户登录
    const userLogin = (data: UserLoginType) => {
      userLoginState.value = data
    }

    //用户登出
    const userLogout = () => {
      userLoginState.value = undefined
    }

    return { userLoginState, userLogin, userLogout }
  },
  { persist: true },
)
